package com.scau.yangsuiyu.estore.dababases.dao;

import com.scau.yangsuiyu.estore.dababases.entity.Goods;
import com.scau.yangsuiyu.estore.dababases.entity.GoodsPhoto;
import com.scau.yangsuiyu.estore.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;

import java.util.List;

/**
 * @author suiyu_yang
 * @description GoodsPhotoDao
 * @date 2019-06-12 22:58
 * @email suiyu_yang@163.com
 */
public class GoodsPhotoDao {
    public void insert(GoodsPhoto goodsPhoto) {
        Session session = HibernateUtil.currentSession();
        Transaction transaction = session.beginTransaction();

        session.save(goodsPhoto);

        transaction.commit();
        HibernateUtil.closeSession();
    }

    public void delete(GoodsPhoto goodsPhoto) {
        Session session = HibernateUtil.currentSession();
        Transaction transaction = session.beginTransaction();

        session.delete(goodsPhoto);

        transaction.commit();
        HibernateUtil.closeSession();
    }

    public void update(GoodsPhoto goodsPhoto) {
        Session session = HibernateUtil.currentSession();
        Transaction transaction = session.beginTransaction();

        session.update(goodsPhoto);

        session.flush();
        transaction.commit();
        HibernateUtil.closeSession();
    }

}
